Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-as-promised

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-as-promised

Extends Chai with assertions about promises.

  • 4.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-17.81%
Maintainers
1
Weekly downloads
 
Created

What is chai-as-promised?

The chai-as-promised npm package extends Chai with a fluent language for asserting facts about promises. It allows developers to work with promises in their test assertions in a more natural and expressive way, which is particularly useful when dealing with asynchronous operations in tests.

What are chai-as-promised's main functionalities?

Asserting a promise is fulfilled

This feature allows you to assert that a promise will be fulfilled. In other words, it checks that the promise will eventually resolve.

expect(promise).to.be.fulfilled;

Asserting a promise is rejected

This feature allows you to assert that a promise will be rejected. This is useful for testing error handling in asynchronous code.

expect(promise).to.be.rejected;

Asserting a promise is rejected with a specific error

With this feature, you can assert that a promise is not only rejected but also that it is rejected with a specific type of error.

expect(promise).to.be.rejectedWith(Error);

Asserting a promise's fulfillment value

This feature allows you to assert what value a promise will be resolved with. The 'eventually' chain is used to wait for the promise to resolve before making the assertion.

expect(promise).to.eventually.equal('foo');

Chaining assertions

chai-as-promised supports chaining assertions, allowing for more complex assertions on the resolved value of a promise.

expect(promise).to.eventually.have.property('bar').that.is.a('string');

Other packages similar to chai-as-promised

Keywords

FAQs

Package last updated on 05 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc